home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
X User Tools
/
X User Tools (O'Reilly and Associates)(1994).ISO
/
sun4c
/
archive
/
tcltk.z
/
tcltk
/
man
/
cat3
/
CrtGenHdlr.3
< prev
next >
Wrap
Text File
|
1994-09-20
|
4KB
|
133 lines
Tk_CreateGenericHandlerT(k3)Library Procedures
_________________________________________________________________
NAME
Tk_CreateGenericHandler, Tk_DeleteGenericHandler - associate
procedure callback with all X events
SYNOPSIS
#include <tk.h>
Tk_CreateGenericHandler(_p_r_o_c, _c_l_i_e_n_t_D_a_t_a)
Tk_DeleteGenericHandler(_p_r_o_c, _c_l_i_e_n_t_D_a_t_a)
ARGUMENTS
Tk_GenericProc *_p_r_o_c (in) Procedure to invoke
whenever any X event
occurs on any
display.
ClientData _c_l_i_e_n_t_D_a_t_a (in) Arbitrary one-word
value to pass to
_p_r_o_c.
_________________________________________________________________
DESCRIPTION
Tk_CreateGenericHandler arranges for _p_r_o_c to be invoked in
the future whenever any X event occurs. This mechanism is
_n_o_t intended for dispatching X events on windows managed by
Tk (you should use Tk_CreateEventHandler for this purpose).
Tk_CreateGenericHandler is intended for other purposes, such
as tracing X events, monitoring events on windows not owned
by Tk, accessing X-related libraries that were not origi-
nally designed for use with Tk, and so on.
The callback to _p_r_o_c will be made by Tk_HandleEvent; this
mechanism only works in programs that dispatch events
through Tk_HandleEvent (or through other Tk procedures that
call Tk_HandleEvent, such as Tk_DoOneEvent or Tk_MainLoop).
_P_r_o_c should have arguments and result that match the type
Tk_GenericProc:
typedef int Tk_GenericProc(
ClientData _c_l_i_e_n_t_D_a_t_a,
XEvent *_e_v_e_n_t_P_t_r);
The _c_l_i_e_n_t_D_a_t_a parameter to _p_r_o_c is a copy of the _c_l_i_e_n_t_D_a_t_a
argument given to Tk_CreateGenericHandler when the callback
was created. Typically, _c_l_i_e_n_t_D_a_t_a points to a data struc-
ture containing application-specific information about how
to handle events. _E_v_e_n_t_P_t_r is a pointer to the X event.
Tk 1
Tk_CreateGenericHandlerT(k3)Library Procedures
Whenever an X event is processed by Tk_HandleEvent, _p_r_o_c is
called. The return value from _p_r_o_c is normally 0. A non-
zero return value indicates that the event is not to be han-
dled further; that is, _p_r_o_c has done all processing that is
to be allowed for the event.
If there are multiple generic event handlers, each one is
called for each event, in the order in which they were esta-
blished.
Tk_DeleteGenericHandler may be called to delete a
previously-created generic event handler: it deletes each
handler it finds that matches the _p_r_o_c and _c_l_i_e_n_t_D_a_t_a argu-
ments. If no such handler exists, then
Tk_DeleteGenericHandler returns without doing anything.
Although Tk supports it, it's probably a bad idea to have
more than one callback with the same _p_r_o_c and _c_l_i_e_n_t_D_a_t_a
arguments.
Establishing a generic event handler does nothing to ensure
that the process will actually receive the X events that the
handler wants to process. For example, it is the caller's
responsibility to invoke XSelectInput to select the desired
events, if that is necessary.
KEYWORDS
bind, callback, event, handler
Tk 2